/**
 * 全局模态框控制
 */
import { defineStore } from 'pinia';

export const useModel = defineStore('model', () => {
  // 当前注册框是否展示
  const registerModel = reactive({
    base: false,   	// 初始注册页
    finish: false,	// 完成页面
  });

  //登录弹窗
  const loginModel = ref(false);

  //忘记密码框
  const forgetModel = reactive({
    first: false,
    second: false,
    phoneCache: '',       //临时缓存手机号码
  })

  // 注册成功跳转完成页
  const changeToRegFinish = () => {
    registerModel.base = false;
    registerModel.finish = true;
  };

  //打开忘记密码弹框
  const changeToForget = () => {
    loginModel.value = false;
    forgetModel.first = true;
  }

  //切换忘记密码(修改密码)到第二步骤(接收验证码)
  const switchForget = () => {
    forgetModel.first = !forgetModel.first;
    forgetModel.second = !forgetModel.second;
  }

  //打开登录弹窗
  const changeToLogin = () => {
    loginModel.value = true
  }

  return {
    registerModel,
    changeToRegFinish,
    loginModel,
    forgetModel,
    changeToForget,
    switchForget,
    changeToLogin
  };
});